﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using BOHVote.BLL;
using BOHVote.Common;

namespace BOH.Reports
{
    public partial class SubjectApplyInfoBlank : System.Web.UI.Page
    {
        string strSubjectID = string.Empty;
        string strApplyPeriodID = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["ApplyPeriod"] != null)
                {
                    strSubjectID = Request.QueryString["SubjectID"].ToString();
                    
                    strApplyPeriodID = Session["ApplyPeriod"].ToString();
                    if (!String.IsNullOrEmpty(strApplyPeriodID))
                        labApplyPeriodTitle.Text = strApplyPeriodID + "年度";
                    
                    BindReport();

                }
            }
        }

        public void SetSubjectName(string subjectID)
        {
            labSubjectName.Text = Subject.getSubjectNameBySubjectID(subjectID);
            Page.Title = "[" + labSubjectName.Text + "]" + Page.Title;
        }

        public void BindReport()
        {
            strSubjectID = Request.QueryString["SubjectID"].ToString();
            SetSubjectName(strSubjectID);
            strApplyPeriodID = Session["ApplyPeriod"].ToString();
            if (!String.IsNullOrEmpty(strSubjectID) && !String.IsNullOrEmpty(strApplyPeriodID))
            {
                DataSet dst = ReportClass.dstSubjectApplyInfoBlank(strSubjectID, strApplyPeriodID);
                BindReportList(dst);
            }
        }

        public string ConvertEnpty(string str)
        {
            if (str.Trim() == "0")
                return string.Empty;
            else
                return str;
        }

        public void BindReportList(DataSet dst)
        {
            if (dst != null && dst.Tables[0].Rows.Count > 0)
            {
                AspNetPager1.RecordCount = dst.Tables[0].Rows.Count;
                if (AspNetPager1.RecordCount != 0)
                {
                    labNoRecord.Visible = false;
                    AspNetPager1.Visible = true;
                    PagedDataSource pds = new PagedDataSource();
                    pds.DataSource = dst.Tables[0].DefaultView;
                    pds.AllowPaging = true;
                    pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
                    labCurrentPage.Text = AspNetPager1.CurrentPageIndex.ToString();
                    labTotlePage.Text = AspNetPager1.PageCount.ToString();
                    labRecord.Text = AspNetPager1.PageSize.ToString();
                    pds.PageSize = AspNetPager1.PageSize;
                    SubjectList.DataSource = pds;
                    SubjectList.DataBind();
                }
                else
                {
                    SubjectList.DataSource = null;
                    SubjectList.DataBind();
                    AspNetPager1.Visible = false;
                    labNoRecord.Visible = true;
                }
            }
            else
            {
                AspNetPager1.Visible = false;
                labNoRecord.Visible = true;
                SubjectList.DataSource = null;
                SubjectList.DataBind();
            }
        }

        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            BindReport();
        }

        protected void SubjectList_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                TableCellCollection tcHeader = e.Row.Cells;
                tcHeader.Clear();
                tcHeader.Add(new TableHeaderCell());
                tcHeader[0].Attributes.Add("rowspan", "2");
                tcHeader[0].Attributes.Add("align", "center");
                tcHeader[0].Attributes.Add("width", "75px");
                tcHeader[0].Text = "学科组<br/>编&nbsp;&nbsp;号";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[1].Attributes.Add("rowspan", "2");
                tcHeader[1].Attributes.Add("align", "center");
                tcHeader[1].Attributes.Add("width", "220px");
                tcHeader[1].Text = "单位名称";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[2].Attributes.Add("rowspan", "2");
                tcHeader[2].Attributes.Add("align", "center");
                tcHeader[2].Attributes.Add("width", "60px");
                tcHeader[2].Text = "姓名";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[3].Attributes.Add("rowspan", "2");
                tcHeader[3].Attributes.Add("align", "center");
                tcHeader[3].Attributes.Add("width", "35px");
                tcHeader[3].Text = "性别";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[4].Attributes.Add("rowspan", "2");
                tcHeader[4].Attributes.Add("align", "center");
                tcHeader[4].Attributes.Add("width", "50px");
                tcHeader[4].Text = "出生<br/>年月";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[5].Attributes.Add("rowspan", "2");
                tcHeader[5].Attributes.Add("align", "center");
                tcHeader[5].Attributes.Add("width", "35px");
                tcHeader[5].Text = "最高<br/>学历";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[6].Attributes.Add("rowspan", "2");
                tcHeader[6].Attributes.Add("align", "center");
                tcHeader[6].Attributes.Add("width", "50px");
                tcHeader[6].Text = "毕业<br/>年月";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[7].Attributes.Add("rowspan", "2");
                tcHeader[7].Attributes.Add("align", "center");
                tcHeader[7].Attributes.Add("width", "75px");
                tcHeader[7].Text = "现任职称";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[8].Attributes.Add("rowspan", "2");
                tcHeader[8].Attributes.Add("align", "center");
                tcHeader[8].Attributes.Add("width", "50px");
                tcHeader[8].Text = "取得<br/>时间";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[9].Attributes.Add("rowspan", "2");
                tcHeader[9].Attributes.Add("align", "center");
                tcHeader[9].Attributes.Add("width", "30px");
                tcHeader[9].Text = "聘用<br/>年限";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[10].Attributes.Add("rowspan", "2");
                tcHeader[10].Attributes.Add("align", "center");
                tcHeader[10].Attributes.Add("width", "160px");
                tcHeader[10].Text = "申报专业";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[11].Attributes.Add("rowspan", "2");
                tcHeader[11].Attributes.Add("align", "center");
                tcHeader[11].Attributes.Add("width", "75px");
                tcHeader[11].Text = "申报职称";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[12].Attributes.Add("rowspan", "2");
                tcHeader[12].Attributes.Add("align", "center");
                tcHeader[12].Attributes.Add("width", "60px");
                tcHeader[12].Text = "申报<br/>类型";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[13].Attributes.Add("colspan", "5");
                tcHeader[13].Attributes.Add("align", "center");
                //tcHeader[13].Attributes.Add("height", "180px");
                tcHeader[13].Text = "各项考核、考试成绩";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[14].Attributes.Add("colspan", "6");
                tcHeader[14].Attributes.Add("align", "center");
                tcHeader[14].Text = "评审结果";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[15].Attributes.Add("rowspan", "2");
                tcHeader[15].Attributes.Add("align", "center");
                tcHeader[15].Attributes.Add("width", "50px");
                tcHeader[15].Text = "备注</th></tr><tr>";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[16].Attributes.Add("height", "35px");
                tcHeader[16].Attributes.Add("align", "center");
                tcHeader[16].Attributes.Add("width", "30px");
                tcHeader[16].Text = "单位政治考核";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[17].Attributes.Add("align", "center");
                tcHeader[17].Attributes.Add("width", "30px");
                tcHeader[17].Text = "单位业务考核";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[18].Attributes.Add("align", "center");
                tcHeader[18].Attributes.Add("width", "45px");
                tcHeader[18].Text = "外语<br/>名称";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[19].Attributes.Add("align", "center");
                tcHeader[19].Attributes.Add("width", "30px");
                tcHeader[19].Text = "外语<br/>成绩";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[20].Attributes.Add("align", "center");
                tcHeader[20].Attributes.Add("width", "30px");
                tcHeader[20].Text = "计算<br/>机<br/>成绩";

                //tcHeader.Add(new TableHeaderCell());
                //tcHeader[21].Attributes.Add("align", "center");
                //tcHeader[21].Attributes.Add("width", "30px");
                //tcHeader[21].Text = "论文<br/>成绩";

                //tcHeader.Add(new TableHeaderCell());
                //tcHeader[22].Attributes.Add("align", "center");
                //tcHeader[22].Attributes.Add("width", "30px");
                //tcHeader[22].Text = "面试<br/>成绩";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[21].Attributes.Add("align", "center");
                tcHeader[21].Attributes.Add("width", "30px");
                tcHeader[21].Text = "综合<br/>评分";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[22].Attributes.Add("align", "center");
                tcHeader[22].Attributes.Add("width", "30px");
                tcHeader[22].Text = "应到<br/>人数";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[23].Attributes.Add("align", "center");
                tcHeader[23].Attributes.Add("width", "30px");
                tcHeader[23].Text = "实到<br/>人数";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[24].Attributes.Add("align", "center");
                tcHeader[24].Attributes.Add("width", "30px");
                tcHeader[24].Text = "同意";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[25].Attributes.Add("align", "center");
                tcHeader[25].Attributes.Add("width", "30px");
                tcHeader[25].Text = "不<br/>同意";

                tcHeader.Add(new TableHeaderCell());
                tcHeader[26].Attributes.Add("align", "center");
                tcHeader[26].Attributes.Add("width", "30px");
                tcHeader[26].Text = "弃权";
            }
        }

        protected void butExecl_Click(object sender, EventArgs e)
        {
            common.ToExcel(SubjectList);
        }


        public override void VerifyRenderingInServerForm(Control control)
        {
        }
    }
}
